<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>PROJEKT Z PRZEDMIOTU SYSTEMY KOMPUTEROWE (SYKO) grupa nr. 16: Plik źródłowy C:/Users/Krzysiek/Desktop/[SYKO]PROJEKT/project_uC_AVR_v2/main.c</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body onload='searchBox.OnSelectItem(0);'>
<!-- Wygenerowano przez Doxygen 1.7.4 -->
<script type="text/javascript"><!--
var searchBox = new SearchBox("searchBox", "search",false,'Szukaj');
--></script>
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">PROJEKT Z PRZEDMIOTU SYSTEMY KOMPUTEROWE (SYKO) grupa nr. 16&#160;<span id="projectnumber">0.01</span></div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Strona&#160;główna</span></a></li>
      <li><a href="pages.html"><span>Dodatkowe&#160;strony</span></a></li>
      <li><a href="modules.html"><span>Moduły</span></a></li>
      <li class="current"><a href="files.html"><span>Pliki</span></a></li>
      <li id="searchli">
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Szukaj" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>Lista&#160;plików</span></a></li>
      <li><a href="globals.html"><span>Globalne</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">C:/Users/Krzysiek/Desktop/[SYKO]PROJEKT/project_uC_AVR_v2/main.c</div>  </div>
</div>
<div class="contents">
<a href="main_8c.html">Idź do dokumentacji tego pliku.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment">================================================================================</span>
<a name="l00003"></a>00003 <span class="comment">        Plik: main.c</span>
<a name="l00004"></a>00004 <span class="comment">--------------------------------------------------------------------------------</span>
<a name="l00005"></a>00005 <span class="comment">        Autorzy: Piotr Zdunek, Mateusz Słowikowski, Krzysztof Wiąckowski</span>
<a name="l00006"></a>00006 <span class="comment">        Projekt:Model mikrokontrolera AVR</span>
<a name="l00007"></a>00007 <span class="comment">        Kompilator: avr-gcc-4.3.5</span>
<a name="l00008"></a>00008 <span class="comment">        Doc: doxygen 1.7.4</span>
<a name="l00009"></a>00009 <span class="comment">--------------------------------------------------------------------------------</span>
<a name="l00010"></a>00010 <span class="comment">        Zawiera:</span>
<a name="l00011"></a>00011 <span class="comment">--------------------------------------------------------------------------------</span>
<a name="l00012"></a>00012 <span class="comment">        Komentarze:</span>
<a name="l00013"></a>00013 <span class="comment">================================================================================</span>
<a name="l00014"></a>00014 <span class="comment">*/</span>
<a name="l00015"></a>00015 
<a name="l00055"></a>00055 
<a name="l00056"></a>00056 
<a name="l00062"></a>00062 <span class="preprocessor">#include &quot;includes.h&quot;</span>           <span class="comment">//biblioteka zawierające pliki nagłowkowe dołączane do projektu</span>
<a name="l00063"></a>00063 
<a name="l00064"></a>00064 
<a name="l00065"></a>00065 <span class="keywordtype">int</span> main(<span class="keywordtype">void</span>){
<a name="l00066"></a>00066     <a class="code" href="group__typy.html#ga07029b78218d1e4f5ef7c04b9c69d8d3" title="szesnastobitowy typ danych o wartosciach od 0 do 65k.">uint16_t</a> T,T2;
<a name="l00067"></a>00067     loadMEMC(<span class="stringliteral">&quot;file_code.bin&quot;</span>); <span class="comment">// Wczytywanie kodu operacji z pliku file_code.bin</span>
<a name="l00068"></a>00068     loadMEMD(<span class="stringliteral">&quot;file_data.bin&quot;</span>); <span class="comment">// Wczytywanie danych z pliku file_data.bin</span>
<a name="l00069"></a>00069     setPC(0x0000); <span class="comment">// Ustawienie rejestru PC na początek (0x0000)</span>
<a name="l00070"></a>00070     InitializeFlagRegister();
<a name="l00071"></a>00071 
<a name="l00072"></a>00072 <span class="preprocessor">#if _DEBUG_MODE</span>
<a name="l00073"></a>00073 <span class="preprocessor"></span>    <span class="keywordtype">int</span> i = 0;
<a name="l00074"></a>00074     printf(<span class="stringliteral">&quot;MEMC\n&quot;</span>);
<a name="l00075"></a>00075     <span class="keywordflow">for</span>(i = 0; i &lt; 10; i++)
<a name="l00076"></a>00076         printf(<span class="stringliteral">&quot;%lx\n&quot;</span>,getMEMC(i));
<a name="l00077"></a>00077 
<a name="l00078"></a>00078     printf(<span class="stringliteral">&quot;MEMD\n&quot;</span>);
<a name="l00079"></a>00079     <span class="keywordflow">for</span>(i = 0; i&lt;10; i++)
<a name="l00080"></a>00080         printf(<span class="stringliteral">&quot;%d\n&quot;</span>,getMEMD(i));
<a name="l00081"></a>00081 <span class="preprocessor">#endif</span>
<a name="l00082"></a>00082 <span class="preprocessor"></span>
<a name="l00083"></a>00083     <span class="keywordflow">for</span>(;;){
<a name="l00084"></a>00084         T=getMEMC(getPC());
<a name="l00085"></a>00085         printf(<span class="stringliteral">&quot;TEST %x, %x\n&quot;</span>, T &amp; 0xFF00, (T &amp; 0xFF00) &gt;&gt; 12);
<a name="l00086"></a>00086         <span class="keywordflow">switch</span>( (T &amp; 0xF000)&gt;&gt; 12)
<a name="l00087"></a>00087         {
<a name="l00088"></a>00088                         <span class="keywordflow">case</span> ID_AND:
<a name="l00089"></a>00089                         {
<a name="l00090"></a>00090                 <a class="code" href="f__and_8c.html#a364a85de3be56c55c68e5c089005cb21">F_AND</a>();
<a name="l00091"></a>00091                 printMEMD();
<a name="l00092"></a>00092                 <span class="keywordflow">break</span>;
<a name="l00093"></a>00093                         }
<a name="l00094"></a>00094             <span class="keywordflow">case</span> ID_BR:
<a name="l00095"></a>00095             {
<a name="l00096"></a>00096                 printf(<span class="stringliteral">&quot;TEST T = %x, BRANCH = %x\n&quot;</span>,T, ((T &amp; 0x000F) &amp; 0b0111));
<a name="l00097"></a>00097                 <span class="keywordflow">switch</span> ( (T &amp; 0x000F) &amp; 0b0111)
<a name="l00098"></a>00098                 {
<a name="l00099"></a>00099                                         <span class="keywordflow">case</span> ID_BRVS:
<a name="l00100"></a>00100                                         {
<a name="l00101"></a>00101                                                 <a class="code" href="f__brvs_8c.html#ad35443397c3353ff1bf13428e7f147ac">F_BRVS</a>();
<a name="l00102"></a>00102                                                 printMEMD();
<a name="l00103"></a>00103                                                 <span class="keywordflow">break</span>;
<a name="l00104"></a>00104                                         }
<a name="l00105"></a>00105                                         <span class="keywordflow">case</span> ID_BRHS:
<a name="l00106"></a>00106                                         {
<a name="l00107"></a>00107                                                 <a class="code" href="f__brhs_8c.html#a2cc49f6ecec8d2685b7e3b9d61003849">F_BRHS</a>();
<a name="l00108"></a>00108                                                 printMEMD();
<a name="l00109"></a>00109                                                 <span class="keywordflow">break</span>;
<a name="l00110"></a>00110                                         }
<a name="l00111"></a>00111                                         <span class="keywordflow">case</span> ID_BRPL:
<a name="l00112"></a>00112                                         {
<a name="l00113"></a>00113                                                 <a class="code" href="f__brpl_8c.html#a3e2dc2424655cb1c4baaf5412d55b905">F_BRPL</a>();
<a name="l00114"></a>00114                                                 printMEMD();
<a name="l00115"></a>00115                                                 <span class="keywordflow">break</span>;
<a name="l00116"></a>00116                                         }
<a name="l00117"></a>00117                                         <span class="keywordflow">case</span> ID_BRCC:
<a name="l00118"></a>00118                                         {
<a name="l00119"></a>00119                                                 <a class="code" href="f__brcc_8c.html#a0f4198eb9c2046726fefe0406dc9e39d">F_BRCC</a>();
<a name="l00120"></a>00120                                                 printMEMD();
<a name="l00121"></a>00121                                                 <span class="keywordflow">break</span>;
<a name="l00122"></a>00122                                         }
<a name="l00123"></a>00123                                         <span class="keywordflow">default</span>:
<a name="l00124"></a>00124                                         {
<a name="l00125"></a>00125                                                 printf(<span class="stringliteral">&quot;Wykryto nieznana instrukcje branch\n&quot;</span>);
<a name="l00126"></a>00126                                                 <span class="keywordflow">return</span> -1;
<a name="l00127"></a>00127                                         }
<a name="l00128"></a>00128                                         <span class="keywordflow">break</span>;
<a name="l00129"></a>00129                 }
<a name="l00130"></a>00130             }
<a name="l00131"></a>00131             <span class="keywordflow">case</span> ID_CL_INC:
<a name="l00132"></a>00132             {
<a name="l00133"></a>00133                 printf(<span class="stringliteral">&quot;TEST T = %lx, CL = %x\n&quot;</span>,T, (T &amp; 0x000F));
<a name="l00134"></a>00134                 <span class="keywordflow">switch</span>((T &amp; 0x000F))
<a name="l00135"></a>00135                 {
<a name="l00136"></a>00136                                         <span class="keywordflow">case</span> ID_CL:
<a name="l00137"></a>00137                                         {
<a name="l00138"></a>00138                                                 <span class="keywordflow">switch</span>( (T &amp; 0x00F0) &gt;&gt; 4)
<a name="l00139"></a>00139                                                 {
<a name="l00140"></a>00140                                                         <span class="keywordflow">case</span> ID_CLS:
<a name="l00141"></a>00141                                                         {
<a name="l00142"></a>00142                                                                 F_CLS();
<a name="l00143"></a>00143                                                                 printMEMD();
<a name="l00144"></a>00144                                                                 <span class="keywordflow">break</span>;
<a name="l00145"></a>00145                                                         }
<a name="l00146"></a>00146                                                         <span class="keywordflow">case</span> ID_CLH:
<a name="l00147"></a>00147                                                         {
<a name="l00148"></a>00148                                                                 <a class="code" href="f__clh_8c.html#a35273f7af06e171f2c5400b7121a3e5e">F_CLH</a>();
<a name="l00149"></a>00149                                                                 printMEMD();
<a name="l00150"></a>00150                                                                 <span class="keywordflow">break</span>;
<a name="l00151"></a>00151                                                         }
<a name="l00152"></a>00152                                                         <span class="keywordflow">default</span>:
<a name="l00153"></a>00153                                                         {
<a name="l00154"></a>00154                                                                 printf(<span class="stringliteral">&quot;BLAD - ID_CL\n&quot;</span>);
<a name="l00155"></a>00155                                                                 <span class="keywordflow">return</span> -1;
<a name="l00156"></a>00156                                                         }
<a name="l00157"></a>00157 
<a name="l00158"></a>00158                                                 }
<a name="l00159"></a>00159                                                 <span class="keywordflow">break</span>;
<a name="l00160"></a>00160                                         }
<a name="l00161"></a>00161                                         <span class="keywordflow">case</span> ID_INC:
<a name="l00162"></a>00162                                         {
<a name="l00163"></a>00163                                                 <a class="code" href="f__inc_8c.html#ad7a4833a58a05baabae7cae1c36e8974">F_INC</a>();
<a name="l00164"></a>00164                                                 printMEMD();
<a name="l00165"></a>00165                                                 <span class="keywordflow">break</span>;
<a name="l00166"></a>00166                                         }
<a name="l00167"></a>00167                                         <span class="keywordflow">default</span>:
<a name="l00168"></a>00168                                         {
<a name="l00169"></a>00169                                                 printf(<span class="stringliteral">&quot;BLAD - ID_CL_INC\n&quot;</span>);
<a name="l00170"></a>00170                                                 <span class="keywordflow">return</span> -1;
<a name="l00171"></a>00171                                         }
<a name="l00172"></a>00172                 }
<a name="l00173"></a>00173                 <span class="keywordflow">break</span>;
<a name="l00174"></a>00174             }
<a name="l00175"></a>00175             <span class="keywordflow">case</span> ID_CPSE:
<a name="l00176"></a>00176             {
<a name="l00177"></a>00177                 <a class="code" href="f__cpse_8c.html#ab8bf17fd972dea01f6af341b72ccc9c2">F_CPSE</a>();
<a name="l00178"></a>00178                 printMEMD();
<a name="l00179"></a>00179                 <span class="keywordflow">break</span>;
<a name="l00180"></a>00180             }
<a name="l00181"></a>00181             <span class="keywordflow">case</span> ID_LD1_LD4v1:
<a name="l00182"></a>00182             {
<a name="l00183"></a>00183                 <span class="keywordflow">switch</span>(T &amp; 0x000F)
<a name="l00184"></a>00184                 {
<a name="l00185"></a>00185                                         <span class="keywordflow">case</span> ID_LD1:
<a name="l00186"></a>00186                                         {
<a name="l00187"></a>00187                                                 F_LD1();
<a name="l00188"></a>00188                                                 printMEMD();
<a name="l00189"></a>00189                                                 <span class="keywordflow">break</span>;
<a name="l00190"></a>00190                                         }
<a name="l00191"></a>00191 <span class="comment">// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!UWAGA!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</span>
<a name="l00192"></a>00192                                         <span class="keywordflow">default</span>:
<a name="l00193"></a>00193                                         {
<a name="l00194"></a>00194                                                 F_LD4();
<a name="l00195"></a>00195                                                 printMEMD();
<a name="l00196"></a>00196                                                 <span class="keywordflow">break</span>;
<a name="l00197"></a>00197                                         }
<a name="l00198"></a>00198 <span class="comment">// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!</span>
<a name="l00199"></a>00199                 }
<a name="l00200"></a>00200             }
<a name="l00201"></a>00201             <span class="keywordflow">case</span> ID_LD2_LD3:
<a name="l00202"></a>00202             {
<a name="l00203"></a>00203                 <span class="keywordflow">switch</span>( T &amp; 0x000F ){
<a name="l00204"></a>00204                                         <span class="keywordflow">case</span> ID_LD2:
<a name="l00205"></a>00205                                         {
<a name="l00206"></a>00206                                                 F_LD2();
<a name="l00207"></a>00207                                                 printMEMD();
<a name="l00208"></a>00208                                                 <span class="keywordflow">break</span>;
<a name="l00209"></a>00209                                         }
<a name="l00210"></a>00210                                         <span class="keywordflow">case</span> ID_LD3:
<a name="l00211"></a>00211                                         {
<a name="l00212"></a>00212                                                 F_LD3();
<a name="l00213"></a>00213                                                 printMEMD();
<a name="l00214"></a>00214                                                 <span class="keywordflow">break</span>;
<a name="l00215"></a>00215                                         }
<a name="l00216"></a>00216                                         <span class="keywordflow">default</span>:
<a name="l00217"></a>00217                                         {
<a name="l00218"></a>00218                                                 printf(<span class="stringliteral">&quot;BLAD ID_LD2_LD3\n&quot;</span>);
<a name="l00219"></a>00219                                                 <span class="keywordflow">return</span> -1;
<a name="l00220"></a>00220                                         }
<a name="l00221"></a>00221                 }
<a name="l00222"></a>00222             }
<a name="l00223"></a>00223             <span class="keywordflow">case</span> ID_LD4v2:
<a name="l00224"></a>00224             {
<a name="l00225"></a>00225                 F_LD4();
<a name="l00226"></a>00226                 printMEMD();
<a name="l00227"></a>00227                 <span class="keywordflow">break</span>;
<a name="l00228"></a>00228             }
<a name="l00229"></a>00229             <span class="keywordflow">default</span>:
<a name="l00230"></a>00230             {
<a name="l00231"></a>00231                 printf(<span class="stringliteral">&quot;Wykryto nieznana instrukcje (PC=0x%lx, T=0x%lx)\r\n&quot;</span>, getPC(), T);
<a name="l00232"></a>00232                 saveMEMD(<span class="stringliteral">&quot;file_data.bin&quot;</span>);
<a name="l00233"></a>00233                 printMEMD();
<a name="l00234"></a>00234                 <span class="keywordflow">return</span> -1;
<a name="l00235"></a>00235             }
<a name="l00236"></a>00236         }
<a name="l00237"></a>00237     }
<a name="l00238"></a>00238 
<a name="l00239"></a>00239     saveMEMD(<span class="stringliteral">&quot;file_data.bin&quot;</span>); <span class="comment">// Zapisanie wyniku działania procesora</span>
<a name="l00240"></a>00240     <span class="keywordflow">return</span> 0;
<a name="l00241"></a>00241 }
</pre></div></div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Pliki</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Funkcje</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Definicje typów</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Definicje</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<hr class="footer"/><address class="footer"><small>Wygenerowano Mon Jun 6 2011 20:13:45 dla PROJEKT Z PRZEDMIOTU SYSTEMY KOMPUTEROWE (SYKO) grupa nr. 16 programem&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address>
</body>
</html>
